#include <QApplication>
#include "trayiconnotificator.h"
#include "trayiconnotificatorconfig.h"
#include "paths.h"
#include "libwishmaster.h"

namespace Wishmaster
{
	TrayIconNotificator::TrayIconNotificator()
	{
		m_trayIcon.setIcon(LibWishmaster::getIcon());
		m_trayIcon.show();
	}

	TrayIconNotificator::~TrayIconNotificator()
	{
	}

	bool TrayIconNotificator::notify(const Notification& notification)
	{
		QString text = notification.text();
		text.replace("\n", "\r\n");
		m_trayIcon.showMessage(notification.title(), text);
		return true;
	}

	QSharedPointer<QWidget> TrayIconNotificator::makeConfig()
	{
		return QSharedPointer<QWidget>(new TrayIconNotificatorConfig());
	}

	bool TrayIconNotificator::updateConfig(const QSharedPointer<QWidget>& config)
	{
		return true;
	}

	QString TrayIconNotificatorFactory::id()
	{
		return QString("System tray icon");
	}

	QSharedPointer<Notificator> TrayIconNotificatorFactory::createNotificator()
	{
		return QSharedPointer<Notificator>(new TrayIconNotificator());
	}
}

Q_EXPORT_PLUGIN2(trayiconnotificator, Wishmaster::TrayIconNotificatorFactory);
